package com.starry.JavaEEStudy;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
import java.io.PrintWriter;

public class RedirectServlet8 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        response.setContentType("text/html;charset=UTF-8;");
        PrintWriter respWriter=response.getWriter();

        respWriter.println("我是重定向的Redirect8<br/>");
        //重定向时request.setAttribute的值不共享
        respWriter.println("获取到的request域设定值key1为："+ request.getAttribute("requestkey1"));
        respWriter.println("<br/>");
        //重定向时getServletContext().setAttribute的值共享
        respWriter.println("获取到的servletContext域设定值contextKey1为："+ getServletContext().getAttribute("contextKey1"));
    }
}
